package com.sky.controller.user;

import com.sky.dto.OrdersSubmitDTO;
import com.sky.result.Result;
import com.sky.service.OrderService;
import com.sky.vo.OrderSubmitVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "订单相关接口")
@RequestMapping("/user/order")
@RestController("userOrderController")
@Slf4j
public class OrderController {
    @Autowired
    private OrderService orderService;

    /**
     * 用户下单
     * @param ordersSubmitDTO 用户下单数据传输对象
     */
    @ApiOperation(value = "用户下单")
    @PostMapping("/submit")
    public Result<OrderSubmitVO> submitOrder(@RequestBody OrdersSubmitDTO ordersSubmitDTO) {
        OrderSubmitVO orderSubmitVO = orderService.addOrder(ordersSubmitDTO);
        return Result.success(orderSubmitVO);
    }

    /**
     * 客户催单
     * @param id 订单id
     */
    @ApiOperation(value = "客户催单")
    @ApiImplicitParam(name = "id", value = "订单id", required = true, paramType = "path", dataType = "long")
    @GetMapping("/reminder/{id}")
    public Result<String> reminder(@PathVariable Long id) {
        orderService.reminderOrder(id);
        return Result.success();
    }

}
